<?php

namespace App\Http\Controllers\Api\User;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Facades\Utils\ValidateParameter;
use App\Facades\Services\User\MessageService;

class MessageController extends Controller
{
    public function createMessage(Request $request)
    {
        $rules = [
            'wechat_doctor_info_id' => 'required|exists:wechat_doctor_infos,id',
            'content' => 'required'
        ];

        ValidateParameter::validate($request,$rules);

        $data= $request->all();

        MessageService::createMessage($data);

        return formatJsonResponse();
    }

    public function doctorCreateReply(Request $request){

    	$rules = [
            'message_id' => 'required|exists:messages,id',
            'reply_content' => 'required'
        ];

        ValidateParameter::validate($request,$rules);

        $data= $request->all();

        MessageService::createDoctorReply($data);

        return formatJsonResponse();
    }

    public function userCreateReply(Request $request){

    	$rules = [
            'message_id' => 'required|exists:messages,id',
            'reply_content' => 'required'
        ];

        ValidateParameter::validate($request,$rules);

        $data= $request->all();

        MessageService::createUserReply($data);

        // MessageService::sendMessageToWeChat();

        return formatJsonResponse();
    }
}
